home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / prbgi097.zip / DRIVERS.INC < prev    next >
Text File  |  1992-12-15  |  9KB  |  331 lines

  1.  
  2.  
  3. MaxAllModes EQU     6;  /* The maximum number of modes supported by any printer */
  4. ; Options field bit definitions
  5.    FormFeedNeeded  EQU  1
  6.    ASCIInumbers    EQU  2
  7.    TransferValueInBytes  EQU  4
  8. ; bits for CompressionType field
  9.    RLE_COMPRESSION EQU  1
  10.  
  11. ; constants definitions
  12. CR          EQU  0Dh;
  13. NL          EQU  0Ah;
  14. _Esc         EQU  01Bh;
  15. _FS          EQU  01Ch;
  16.  
  17. COMMENT \ ******************************************************************
  18.  
  19.    /* When command sending to printer is divided into two parts  */
  20.    /* it means that first Str1 is sending then needed parameter */
  21.    /* and at last Str2. Of cource Str2 may be empty one */
  22.  
  23. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  24.  
  25. DriversNo = 0;
  26. DriverDefOnlySize = 24h;   /* without modes definitions */
  27. ModeDefSize = 2Ah;
  28. ConstDriverDefSize = DriverDefOnlySize + ModeDefSize*MaxAllModes;   /* with modes defined, without strings */
  29. string_offset = ConstDriverDefSize;
  30.  
  31. ModeDefAddr = 0;
  32. DriverDefAddr = 0;
  33.  
  34. GenString  MACRO  Stype,str
  35.       ifidni <&str>,<NULL>
  36.          dw  ConstDriverDefSize
  37.          EXITM
  38.       endif
  39.       ifb   <&str>
  40.          dw  ConstDriverDefSize
  41.          EXITM
  42.       endif
  43.       o1 = $
  44.       org DriverDefAddr+string_offset
  45.       o2 = $
  46.       l  = 0
  47.       ifdifi <&Stype>,<C>
  48.          db   ?
  49.          db   str
  50.          l  = $-o2
  51.          ifidni <&Stype>,<Both>
  52.             db  0
  53.          else
  54.             ifdifi <&Stype>,<Pascal>
  55.                err Wrong string type specified
  56.             endif
  57.          endif
  58.          org  o2
  59.          db   l-1;        string length
  60.       else
  61.          ifidni <&Stype>,<C>
  62.             db   str
  63.             db   0
  64.             l  = $-o2
  65.          endif
  66.       endif
  67.       org  o1
  68.       dw    string_offset
  69.       ifidni <&Stype>,<Both>
  70.              l = l+1;
  71.       endif
  72.       string_offset = string_offset+l
  73.    ENDM
  74.  
  75. GenPString  MACRO  str
  76.             GenString  <Pascal>,<&str>
  77.             ENDM
  78.  
  79.  
  80. genstmnt    MACRO a,b,c,d,e,f,g,h
  81.             a&b   c&d   e&f&g&h
  82.             ENDM
  83.  
  84. DriverDef  MACRO
  85.            DriverDefAddr = $
  86.            org   ConstDriverDefSize
  87.            db    0;    ; NULL strings points here
  88.            org   DriverDefAddr
  89.            string_offset = ConstDriverDefSize+1;
  90.            genstmnt  <DriverDefOffs_>,%DriversNo,<=>,,<DriverDefAddr-PRT__Drivers>
  91.            ModesNo = 0
  92.            dw      ? ; place for Driver definition size
  93.            db      ? ; place for ModesNo
  94.            ENDM
  95.  
  96. EndDriverDef  MACRO
  97.               l     = $
  98.               ORG   DriverDefAddr
  99.               dw    string_offset   ; driver definition size
  100.               db    ModesNo;
  101.               org   l
  102.               l = $-DriverDefAddr
  103.               if l GT ConstDriverDefSize
  104.                  err ConstDriverDefSize === &l&
  105.                  Display "ConstDriverDefSize = &l&"
  106.               endif
  107.               ModesNo   = 0;
  108.               org   DriverDefAddr+string_offset
  109.               DriversNo = DriversNo + 1;
  110.            ENDM
  111.  
  112. CompressionType MACRO  a
  113.                 ifb    <&a>
  114.             db     0
  115.         else
  116.             db     a
  117.         endif
  118.                 ENDM
  119.  
  120. DrDisp          MACRO no,str
  121.         Display "&no&. &str&"
  122.                 ENDM
  123.  
  124. DriverName      MACRO  s
  125.                 DrDisp    %DriversNo,<&s>
  126.                 genstmnt  <DriverName_>,%DriversNo,<EQU>,,<s>
  127.                 ENDM
  128.  
  129.  
  130. InitPRTStr        MACRO  s      ;  /* Init PRT string */
  131.                 GenPString <&s>
  132.                 ENDM
  133. EndPRTStr         MACRO  s      ;  /* End PRT string */
  134.                 GenPString <&s>
  135.                 ENDM
  136. CompressedStr     MACRO  s      ;  /* Compress mode string */
  137.                 GenPString  <&s>
  138.                 ENDM
  139. UncompressedStr   MACRO  s      ;  /* Compress mode string */
  140.                 GenPString <&s>
  141.                 ENDM
  142.  
  143. LeftMargin     MACRO  s1,s2,mult,div      ;
  144.                 GenPString <&s1>
  145.                 GenPString <&s2>
  146.                 dw         mult
  147.                 dw         div
  148.                 ENDM
  149.  
  150. TopMargin     MACRO  s1,s2,mult,div      ;
  151.                 GenPString <&s1>
  152.                 GenPString <&s2>
  153.                 dw         mult
  154.                 dw         div
  155.                 ENDM
  156.  
  157. ColorsStrings   Macro s1,s2,map
  158.                 GenPString <&s1>
  159.                 GenPString <&s2>
  160.                 ifb   <&map>
  161.                       dw   0
  162.                 else
  163.                       ifidni <&map>,<NULL>
  164.                              dw   0
  165.                       else
  166.                              GenCString <&map> ; we do not need null terminated string
  167.                       endif
  168.                 endif
  169.                 ENDM
  170.  
  171. Options         Macro  b
  172.                 ifb    <&b>
  173.                        dw    0
  174.                 else
  175.                        dw     b
  176.                 endif
  177.                 ENDM
  178.  
  179. __ModeName      MACRO  s
  180.                 GenString <Both>,<&s>
  181.                 ENDM
  182.  
  183.  
  184. ModeDef   MACRO XPinch,YPinch,ColorsNo,ModeName;
  185.           ModeDefAddr  = $;
  186.           if  DriverDefOnlySize EQ 0
  187.               DriverDefOnlySize = $-DriverDefAddr
  188.           endif
  189.           if ModesNo EQ 0
  190.              if DriverDefOnlySize NE $-DriverDefAddr
  191.                 err Wrong driver definition
  192.              endif
  193.           endif
  194.           dw   XPinch,YPinch
  195.           dw   ColorsNo
  196.           ifnb <&ModeName>
  197.                __ModeName <'&ModName'>
  198.           else
  199.               mname  CATSTR  <'>,<&XPinch>,<x&YPinch>
  200.               if     ColorsNo GT 2
  201.                      mname  CATSTR  mname,<(&ColorsNo>,< colors)>
  202.               endif
  203.               mname  CATSTR  mname,<'>
  204.               __ModeName  <%mname>
  205.           endif
  206.           ModesNo = ModesNo+1;
  207.           ENDM
  208.  
  209. ModeOptions MACRO o1;
  210.             l  = 0;
  211.             ifidni <&o1>,<Planes>
  212.                 l  = 1;
  213.             endif
  214.             ifidni <&o1>,<SimPlanes>
  215.                 l  = 3;
  216.             endif
  217.             ifnb  <&o1>
  218.                ifdif <&o1>,<0>
  219.                   ife l
  220.                      err Wrong argument &o1& in macro ModeOptions
  221.                   endif
  222.                endif
  223.             endif
  224.             dw    l;
  225.             ENDM
  226.  
  227. ColorPalette     MACRO  palette
  228.            ifb   <&palette>
  229.                  dw   0
  230.            else
  231.               ifidni   <&palette>,<NULL>
  232.                        dw  0
  233.               else
  234.                        GenCString <&palette>
  235.               endif
  236.            endif
  237.            ENDM
  238.  
  239. InitGraphStr MACRO s;       /* init graph string  */
  240.            GenPString <&s>
  241.            ENDM
  242. EndGraphStr MACRO s;       /* end graph string  */
  243.            GenPString <&s>
  244.            ENDM
  245.  
  246. PicWidth Macro s1,s2,multiplier,divisor;  /* Def. picture width command, multiplier, divisor */
  247.          GenPString <&s1>
  248.          GenPString <&s2>
  249.          ifnb  <&multiplier>
  250.               dw multiplier
  251.          else
  252.               dw 1
  253.          endif
  254.          ifnb  <&divisor>
  255.               dw divisor
  256.          else
  257.               dw 1
  258.          endif
  259.          endm
  260.  
  261. InitTransfer MACRO s1,s2,SubValue; /* init graphic mode cmnd. */
  262.            GenPString <&s1>
  263.            GenPString <&s2>
  264.            ifb        <&SubValue>
  265.                       dw  0
  266.            else
  267.                       dw  &SubValue
  268.            endif
  269.            ENDM
  270.  
  271. PinsPerHead MACRO p;      ;/* number of pins in a head */
  272.                           ;/* 1 - for laser printers */
  273.             db     p
  274.             ENDM
  275.  
  276. PixelsStep  MACRO  p;       /* vertical density / pins distance */
  277.             db      p
  278.             ENDM
  279.  
  280. EolnStr     Macro s
  281.            GenPString <&s>
  282.            ENDM
  283.  
  284. SmallEoln  MACRO  s1,s2,mult,div
  285.                            ; /* SmallEoln multipier and dividend are the numbers */
  286.                            ; /* needed to adjust paper for one pins distance,    */
  287.                            ; /* in the case when SmallEoln command adjusts paper */
  288.                            ; /* not at vertical pixel distance but some other value */
  289.            GenPString <&s1>
  290.            GenPString <&s2>
  291.            dw        mult,div
  292.            if    ModeDefSize NE $-ModeDefAddr
  293.               err Wrong mode definition
  294.            endif
  295.            ENDM
  296.  
  297. EndDrivers  Macro
  298.       align  2
  299.    DriversNamesOffsets label word
  300.    d = 0
  301.    offs = 2*DriversNo
  302.    Rept DriversNo
  303.         dw        offs ; driver definition offset
  304.         genstmnt  <l>,,< SIZESTR >,,<DriverName_>,%d
  305.         offs = offs + l
  306.         d = d+1
  307.    ENDM
  308.    d = 0
  309.    Rept DriversNo
  310.         genstmnt  <l>,,< SIZESTR >,,<DriverName_>,%d
  311.         db        l-2
  312.         genstmnt  ,,< db >,,<DriverName_>,%d
  313.         db    0
  314.         d = d+1
  315.    ENDM
  316.  
  317.    org PRT__DriversNo
  318.        if   DriversNo GT MaxDriversNo
  319.             err Too many drivers definitions, change MaxDriversNo at the file beginning
  320.             DriversNo = MaxDriversNo;
  321.        endif
  322.        dw   DriversNo-1
  323.        d = 0
  324.        org DriversOffsets
  325.        Rept DriversNo
  326.             genstmnt  <D_offs>,,<=>,,<DriverDefOffs_>,%d
  327.             dw        D_offs; driver definition offset
  328.             d = d+1
  329.        ENDM
  330.  
  331.        ENDM